package com.ymttest.database.sqlwapper.sqrefund;

import java.util.HashMap;
import java.util.List;

import com.ymt.database.SqlManager;
import com.ymttest.database.model.sqrefund.RefundProductDetail;

public class RefundProductDetailWrapper {
	
	SqlManager manager;

	public RefundProductDetailWrapper() {
		manager = new SqlManager("sqrefund");
	}

	@SuppressWarnings("unchecked")
	public RefundProductDetail selectByPrimaryKey(Long id) {

		RefundProductDetail refundProductDetail = null;
		List<RefundProductDetail> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.sqrefund.RefundProductDetailMapper.selectByPrimaryKey",
						id);
		manager.commit();

		if (result.size() > 0) {
			refundProductDetail = result.get(0);
		}

		return refundProductDetail;
	}
	
	@SuppressWarnings("unchecked")
	public List<RefundProductDetail> selectByOrderId(Long orderId) {

		List<RefundProductDetail> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.sqrefund.RefundProductDetailMapper.selectByOrderId",
						orderId);
		manager.commit();

		return result;
	}
	
	@SuppressWarnings("unchecked")
	public List<RefundProductDetail> selectByRefundNoAndOrderId(String refundNo, Long orderId) {
		
		HashMap<String, Object> map = new HashMap<String, Object>();
		
		map.put("refund_no", refundNo);
		map.put("order_id", orderId);
		
		List<RefundProductDetail> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.sqrefund.RefundProductDetailMapper.selectByRefundNoAndOrderId",
						map);
		manager.commit();

		return result;
	}
	
	@SuppressWarnings("unchecked")
	public List<RefundProductDetail> selectByOrderIdAndCatalogId(Long orderId, String catalogId) {
		
		HashMap<String, Object> map = new HashMap<String, Object>();
		
		map.put("order_id", orderId);
		map.put("catalog_id", catalogId);
		
		List<RefundProductDetail> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.sqrefund.RefundProductDetailMapper.selectByOrderIdAndCatalogId",
						map);
		manager.commit();

		return result;
	}
	
	@SuppressWarnings("unchecked")
	public List<RefundProductDetail> selectLatestByOrderIdAndCatalogId(Long orderId, String catalogId) {
		
		HashMap<String, Object> map = new HashMap<String, Object>();
		
		map.put("order_id", orderId);
		map.put("catalog_id", catalogId);
		
		List<RefundProductDetail> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.sqrefund.RefundProductDetailMapper.selectLatestByOrderIdAndCatalogId",
						map);
		manager.commit();

		return result;
	}
	
	@SuppressWarnings("unchecked")
	public List<RefundProductDetail> selectByRefundBillNoAndCatalogId(String refundBillNo, String catalogId) {
		
		HashMap<String, String> map = new HashMap<String, String>();
		
		map.put("refund_no", refundBillNo);
		map.put("catalog_id", catalogId);
		
		List<RefundProductDetail> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.sqrefund.RefundProductDetailMapper.selectByRefundBillNoAndCatalogId",
						map);
		manager.commit();

		return result;
	}
	
	public static void main(String[] args) {
		
		RefundProductDetailWrapper test = new RefundProductDetailWrapper();
		
//		SellerLevelHistory sellerLevelHistory = new SellerLevelHistory();
//		
//		sellerLevelHistory.setDDate(YMTDateUtil.getDate());
//		sellerLevelHistory.setSellerID(24635724);
//		sellerLevelHistory.setUpdateTime(YMTDateUtil.getDate());
//		sellerLevelHistory.setUnconfirm_amount(BigDecimal.TEN);
//		
		System.out.println(test.selectByOrderIdAndCatalogId(13088928699L, "c8780288"));
	}
}
